package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.dao.IDBCallBack;
import com.baichang.framework.excelption.DBException;
import org.springframework.stereotype.Repository;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.ParamsDao;
import com.baichang.taoshunda.entity.Params;

import java.util.Map;

@Repository
public class ParamsDaoImpl extends BaseDaoImpl<Params> implements ParamsDao {
    /**
     * 接口
     * 根据参数类型，参数编号获取对应的值
     *
     * @param paramsType 参数类型
     * @param paramsId   参数编号
     *                   武圣路
     * @return
     */
    @Override
    public Map<String, Object> getParamsValue(int paramsType, int paramsId) {
        String sql = "SELECT * FROM `t_params` WHERE `type_id` = ? AND `id` = ? ";
        return queryForMap(sql, paramsType, paramsId);
    }

    /**
     * 修改参数
     */
    @Override
    public int update(final Map<String, Object> map, final int id) throws DBException {
        return callBack(new IDBCallBack<Integer>() {
            @Override
            public Integer callBack() {
                return update(" id=? ", map, id);
            }
        });
    }

    /**
     * 查询
     *
     * @return
     */
    @Override
    public Params getParamsInfo() {
        String sql = "SELECT * FROM t_params WHERE id = 12";
        return queryForBean(sql);
    }

    /**
     * 获取参数值
     *
     * @param id
     * @return
     */
    @Override
    public Map<String, Object> queryParams(int id) {
        String sql = "SELECT  value AS videoMoney FROM t_params WHERE id = ?";
        return queryForMap(sql, id);
    }
}